/*
 * app_led.h
 *
 *  Created on: 2023年7月14日
 *      Author: zlw
 */

#ifndef DS_APP_INS_APP_LED_H_
#define DS_APP_INS_APP_LED_H_

#include "bsp_gpio.h"
#include "softwareMultiTimer.h"

typedef enum {
  NONE_BLINK,
  REGIEST_BLINK,
  REG_SUCCESS_BLINK,
  LED_MODEL_BLINK,
  FIND_ME_BLINK,
  ALARM_BLINK,
  POWER_ON_BLINK,
  CLI_TEST_BLINK,
}blinkType_t;

typedef struct{
  ds_gpio_t *ledRed;
  ds_gpio_t *ledGreen;
  ds_gpio_t *ledBlue;
  uint8_t bitMaskRed;
  uint8_t bitMaskGreen;
  uint8_t bitMaskBlue;
  uint8_t bitOffset;
  uint8_t blinkCycleTotal;
  uint8_t bitTimes;
  blinkType_t type;
  MultiTimer* timer;
  MultiTimerCallback_t callbackFun;
}led_ins_t;

#define BIT_MAST_TIMER_UNIT (32768 / 8)

bool ledStateGet(void);

void led_blink_finist_callback(blinkType_t type);
void led_driver_init(led_ins_t *ledDrive, MultiTimer* timer, ds_gpio_t ledGreen, ds_gpio_t ledOrange, ds_gpio_t ledRed, uint8_t *data, blinkType_t type);

/******************keypad signal led ***************************/

typedef struct{
  uint8_t bitMaskRed;
  uint8_t bitMaskGreen;
  uint8_t bitMaskBlue;
  uint8_t bitOffset;
  uint8_t blinkCycleTotal;
  uint8_t bitTimes;
  uint8_t blinkCycleOffset;
  blinkType_t type;
  MultiTimer* timer;
  MultiTimerCallback_t callbackFun;
}keypad_signal_led_t;

typedef struct{
  uint8_t bitMaskalarm;
  uint8_t bitOffset;
  uint8_t blinkCycleTotal;
  uint8_t bitTimes;
  uint8_t blinkCycleOffset;
  MultiTimer* timer;
  MultiTimerCallback_t callbackFun;
}keypad_alarm_led_t;

typedef enum{
  BACK_LIGHT = 0,
  FAULT_ORANGE = 3,
  SIGNAL_ORANGE = 4,
  SIGNAL_GREEN = 5,
  SIGNAL_RED = 6,
  ALERM_RED = 7,
  BAT_CTRL = 8,
  NFC_RST = 12,
  LIGHT_CTRL = 13,
  DEPLOY_GREEN = 14,
  DEPLOY_BLUE = 15,
  ALL_GPIO = 16
}keyPadLed_t;

void keyPad_led_on(keyPadLed_t led);
void keyPad_led_off(keyPadLed_t led);
void keyPad_led_send(void);

void keypad_signal_led_blink_start_init(keypad_signal_led_t *keyPadLed, MultiTimer* timer, uint8_t *data, blinkType_t type);
void keypad_alarm_led_blink_start_init(keypad_alarm_led_t *keyPadLed, MultiTimer* timer, uint8_t *data);

#endif /* DS_APP_INS_APP_LED_H_ */
